<?
	include_once('cfg.php');
	include_once('function.php');
	
if(@$event=='exit') {
	unset ($u_id);
	unset ($u_pass);
	unset ($u_login);
	unset ($u_admin);
	
	session_unregister ('u_id');
	session_unregister ('u_pass');
	session_unregister ('u_login');
	session_unregister ('u_admin');
	
	// Unset âñå ïåðåìåííûå ñåññèè.
	session_unset();
	// Íàêîíåö, ðàçðóøèòü ñåññèþ.
	session_destroy();

}
if((session_is_registered('u_login')) and (session_is_registered('u_pass'))){
$u_id=$_SESSION['u_id'];
$u_login=$_SESSION['u_login'];
$u_pass=$_SESSION['u_pass'];
$u_admin=$_SESSION['u_admin'];
}
if(@$u_login){
	// ---- Èìÿ è ïàðîëü ----//
	$e_query = "SELECT * FROM auth_users WHERE `login` = '$u_login'";
	$e_result = MYSQL_QUERY($e_query);
	$e_numrow = @MYSQL_NUMROWS($e_result);
	if($e_numrow>0){
		$i=0;
		$MyName = mysql_result($e_result,$i,"login");
		$MyPass = mysql_result($e_result,$i,"passw");
		$MyAdmin = mysql_result($e_result,$i,"admin");
		$MyId = mysql_result($e_result,$i,"id");
	}
// ---------------- End ----------------//
	if($u_login == @$MyName AND $u_pass == @$MyPass)
	{
		session_register('u_id');
		session_register('u_login');
		session_register('u_pass');
		session_register('u_admin');
		
		
		$_SESSION['u_id']=$MyId;
		$_SESSION['u_login']=$u_login;
		$_SESSION['u_pass']=$u_pass;
		$_SESSION['u_admin']=$MyAdmin;
	}else{
	?>
		<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
		<html>
		<head>
			<title><?echo title;?></title>
			<link type="text/css" href="<?=host_name?>/css/style.css" rel="stylesheet">
		</head>
		<body style="font-size: 11px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" bottommargin="0" leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0" topmargin="0">
		
		<table width="100%" height="100%" cellpadding="0" cellspacing="0">
		<tr>
			<td height="35%" align="center" valign="bottom">
				<img src="/admin/cms-img/logo.gif" alt="" width="250" height="75" border="0">
				<br>
			</td>
		</tr>
		<tr>
			<td height="145" align="center" style="border-top: 1px solid #E8E8E8; border-bottom: 1px solid #E8E8E8; background-color: #F9F9FA;">
				<div align="center">
					<b><font color="#FF0000">Ëîãèí èëè ïàðîëü ââåäåí íå âåðíî!</font></b><br>
					<form action="?" method=post>
					<table border="0">
					<tr>
						<td width="100">&nbsp;</td>
						<td width="150">Ëîãèí</td>
						<td width="150">Ïàðîëü</td>
						<td width="100">&nbsp;</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td><input type=text name=u_login></td>
						<td><input type=password name=u_pass></td>
						<td><input type=submit value='Âîéòè'></td>
					</tr>
					</table>
					</form>
				</div>
			</td>
		</tr>
		<tr>
			<td valign="top" align="center">
				<br><a href="" class="tn_b">Ðàçðàáîòêà Èíòåðíåò ñàéòîâ</a>
			</td>
		</tr>
		</table>
		</body>
		</html>
	<?
	exit;
	}
}
else
{
?>
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
	<html>
	<head>
		<title><?echo title;?></title>
		<link type="text/css" href="<?=host_name?>/css/style.css" rel="stylesheet">
	</head>
	<body style="font-size: 11px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" bottommargin="0" leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0" topmargin="0">
	
	<table width="100%" height="100%" cellpadding="0" cellspacing="0">
	<tr>
		<td height="35%" align="center" valign="bottom">
			<img src="/admin/cms-img/logo.gif" alt="" width="250" height="75" border="0">
			<br>
		</td>
	</tr>
	<tr>
		<td height="145" align="center" style="border-top: 1px solid #E8E8E8; border-bottom: 1px solid #E8E8E8; background-color: #F9F9FA;">
			<div align="center">
				<form action="?" method=post>
				<table border="0">
				<tr>
					<td width="100">&nbsp;</td>
					<td width="150">Ëîãèí</td>
					<td width="150">Ïàðîëü</td>
					<td width="100">&nbsp;</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td><input type=text name=u_login></td>
					<td><input type=password name=u_pass></td>
					<td><input type=submit value='Âîéòè'></td>
				</tr>
				</table>
				</form>
			</div>
		</td>
	</tr>
	<tr>
		<td valign="top" align="center">
			<br><a href="" class="tn_b">Ðàçðàáîòêà Èíòåðíåò ñàéòîâ</a>
		</td>
	</tr>
	</table>
	</body>
	</html>
<?
exit;
}
?>
